/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package ua.yandex.skipasssystem.skipass;

import java.util.Date;

/**
 *
 * @author Mitya
 */
public class WorkDaySkiPassLimited extends AbstractSkiPass implements WorkDay,
        LimitedPass {

    private int numberOfRides;

    WorkDaySkiPassLimited(Date activationDate, Date expirationDate,
            NumberOfRides numberOfRides) {

        this.activationDate = activationDate;
        this.expirationDate = expirationDate;
        this.numberOfRides = numberOfRides.getNumberOfRides();
        this.type = SkiPassType.WORK_DAY_LIMITED;
    }

    @Override
    public void decreseNumberOfRides() {
        if (numberOfRides > 0) {
            numberOfRides--;
        }
    }

    @Override
    public int getNumberOfRides() {
        return numberOfRides;
    }

    @Override
    public boolean isValid() {

        if (numberOfRides <= 0) {
            return false;
        }

        if (isBlocked()) {
            return false;
        }

        if (!isWorkday()) {
            System.out.println("Not WorkDay!!!");
            return false;
        }

        return true;
    }

    @Override
    public String toString() {
        return super.toString() + " " + getNumberOfRides();
    }

    @Override
    public SkiPassType getType() {
        return this.type;
    }
}
